#include "Param.h"
#include "KoDoFlash.h"

#define FIRSTINITFLAH           0x44

struct param ParamData;

void Param_Init(void) //恢复默认参数
{
    ParamData.NRF_Channel= 0;
    ParamData.OffSet_En  = 0;
    ParamData.OffSet_Rol = 0;
    ParamData.OffSet_Pit = 0;
    ParamData.OffSet_Yaw = 0;
    ParamData.OffSet_Thr = 0;
    ParamData.FirstInitFlag = FIRSTINITFLAH;

    Param_SAVE();
}

void Param_SAVE(void)
{
    Flash_Write((u8 *)(&ParamData),sizeof(ParamData));
}

void Param_READ(void)
{
    Flash_Read((u8 *)(&ParamData),sizeof(ParamData));
    if(ParamData.FirstInitFlag != FIRSTINITFLAH) //板子从未初始化
    {
        Param_Init();
    }
}
